<!DOCTYPE HTML>
<html>
<head>
    <title> 中供通ERP管理系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <link rel="stylesheet" type="text/css" href="/assets/easyui/themes/default/easyui.css">
    <link href="/css/login.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/assets/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="/assets/easyui/jquery.easyui.min.js"></script>
</head>
<body class="login">
    <div class="login_m">
        <div class="login_logo"><img src="/img/logo.png" width="196" height="46"></div>
        <div class="login_boder">
            <div class="login_padding" id="login_model">
                <h2>用户名</h2>
                <label>
                    <input type="text" id="username" class="txt_input txt_input2" placeholder="请输入用户名" value="">
                </label>
                <h2>密码</h2>
                <label>
                    <input type="password" name="textfield2" id="userpwd" class="txt_input" placeholder="请输入密码" value="">
                </label>

                <div class="rem_sub">
                    <label>
                        <input type="submit" class="sub_button" name="button" onclick="login()" id="button" value="登录" style="opacity: 0.7;">
                    </label>
                </div>
            </div>
        </div>
    </div>
    <script>
        if(window !=top){
            top.location.href=location.href;
        }
        $(document).keyup(function (event) {
            if (event.keyCode === 13) {
                $("#button").trigger("click");
            }
        })
        function login() {
            var name = $("#username").val();
            var psd = $("#userpwd").val();
            if(name.length == 0){
                $.messager.alert("消息", "用户名不能为空！", "error");
                return;
            }
            if(psd.length == 0){
                $.messager.alert("消息", "密码不能为空！", "error");
                return;
            }

            $.ajax({
                type: "POST",
                dataType: "json",
                url: "/login",
                headers: {
                    'X-CSRF-TOKEN': '{{ csrf_token() }}'
                },
                data: { name: name, psd:psd },
                success: function (data) {
                    if(data.code == 200){
                        window.location.href = data.data;
                    }else{
                        $.messager.alert("登录消息", data.data , "error");
                    }
                },
            });
        }
    </script>
</body>
</html>
